/****************************** Module Header ******************************\
* Module Name:	CppDllExport.cpp
* Project:		CppDllExport
* Copyright (c) Microsoft Corporation.
* 
* Defines the exported functions for the DLL application.
* 
* This source is subject to the Microsoft Public License.
* See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
* All other rights reserved.
* 
* History:
* * 1/21/2009 11:04 PM Jialiang Ge Created
\***************************************************************************/

#pragma region Includes
#include "stdafx.h"
#include "CppDllExport.h"
#pragma endregion


/////////////////////////////////////////////////////////////////////////////
// Define the exported data.
// 

// An exported/imported global data with a DEF file
int g_nVal1 = 1;

SYMBOL_DECLSPEC int g_nVal2 = 2;


/////////////////////////////////////////////////////////////////////////////
// Define the exported methods.
// 

void /*__cdecl*/ HelloWorld(_TCHAR** pRet)
{
	*pRet = _T("HelloWorld");
}

void __stdcall stdcall_HelloWorld(_TCHAR** pRet)
{
	*pRet = _T("HelloWorld");
}

SYMBOL_DECLSPEC int /*__cdecl*/ Add(int a, int b)
{
	return a + b;
}

SYMBOL_DECLSPEC int __stdcall stdcall_Add(int a, int b)
{
	return a + b;
}

SYMBOL_DECLSPEC float /*__cdecl*/ Div(float a, float b)
{
	return a / b;
}

SYMBOL_DECLSPEC float __stdcall stdcall_Div(float a, float b)
{
	return a / b;
}

SYMBOL_DECLSPEC int __stdcall Max(int a, int b, PFN_COMPARE cmpFunc)
{
	// Make the callback to the comparison function

	// If a is greater than b, return a.
	if (1 == (*cmpFunc)(a, b)) return a;	
	// If b is greater than or equal to a, return b.
	return b;
}


/////////////////////////////////////////////////////////////////////////////
// Define the exported class.
// 

CppSimpleClass::CppSimpleClass() : m_fField(0.0f)
{
}

float CppSimpleClass::Increment(float fVal)
{
	return m_fField += fVal;
}